﻿using IterationLife.FootballTeaching.Models;
using Util.Datas.Ef;

namespace IterationLife.Datas.Mappings.FootballTeachings {
    /// <summary>
    /// 课时映射配置
    /// </summary>
    public class LessonMap : AggregateRootMapBase<Lesson> {
        /// <summary>
        /// 映射表
        /// </summary>
        protected override void MapTable() {
            ToTable( "Lessons", "FootballTeaching");
        }
        
        /// <summary>
        /// 映射属性
        /// </summary>
        protected override void MapProperties() {
            //课时编号
            Property(t => t.Id)
                .HasColumnName("LessonId");
            //封面图
            Property(t => t.BannerJsonStr)
                .HasColumnName("Banner");
            //视频
            Property(t => t.VideoJsonStr)
                .HasColumnName("Video");
        }
        
        /// <summary>
        /// 映射导航属性
        /// </summary>
        protected override void MapAssociations() {
            //章节
            HasRequired(t => t.Chapter)
                .WithMany(t => t.Lessons)
                .HasForeignKey(d => d.ChapterId);
        }
    }
}